********************************************************************************
*************************************Generosity*********************************
********************************************************************************

*Data: Comparative Welfare Entitlements Dataset (CWED)


import delimited cwed-unemp.csv, varnames(1) clear

gen country=""

replace country="AU" if countryabbrev=="AUS"
replace country="AT" if countryabbrev=="AUT"
replace country="BE" if countryabbrev=="BEL"
replace country="BG" if countryabbrev=="BGR"
replace country="CA" if countryabbrev=="CAN"
replace country="CH" if countryabbrev=="CHE"
replace country="CZ" if countryabbrev=="CZE"
replace country="PT" if countryabbrev=="PRT"
replace country="DK" if countryabbrev=="DNK"
replace country="ES" if countryabbrev=="ESP"
replace country="EE" if countryabbrev=="EST"
replace country="FI" if countryabbrev=="FIN"
replace country="EL" if countryabbrev=="GRC"
replace country="HU" if countryabbrev=="HUN"
replace country="IT" if countryabbrev=="ITA"
replace country="FR" if countryabbrev=="FRA"
replace country="UK" if countryabbrev=="GBR"
replace country="IE" if countryabbrev=="IRL"
replace country="NL" if countryabbrev=="NLD"
replace country="NO" if countryabbrev=="NOR"
replace country="SE" if countryabbrev=="SWE"
replace country="DE" if countryabbrev=="DEU"
replace country="JP" if countryabbrev=="JPN"
replace country="KR" if countryabbrev=="KOR"
replace country="LT" if countryabbrev=="LTU"
replace country="LV" if countryabbrev=="LVA"
replace country="NZ" if countryabbrev=="NZL"
replace country="PL" if countryabbrev=="POL"
replace country="RO" if countryabbrev=="ROU"
replace country="SK" if countryabbrev=="SVK"
replace country="SI" if countryabbrev=="SVN"
replace country="TW" if countryabbrev=="TWN"
replace country="US" if countryabbrev=="USA"


drop countryabbrev

order country

gen rep=(us100+uc1000)/2
rename uegen gen
rename uequal con
rename uecov cov
rename uewait wait
rename uerep rep
rename uedur dur


*Select countries and years

gen sample=.

foreach x in $ctr {
	replace sample=1 if country=="`x'"
}
	
foreach y in $year {
	replace sample=sample+1 if year==20`y'
}

keep if sample==2
drop sample



*Top-coding duration and qualification period

replace dur=156 if dur>156 & dur!=.
replace con=156 if con>156 & con!=.


*Standardize

foreach x of varlist gen con cov wait rep dur {
sum `x'
gen r`x'=`x'-r(mean)
egen s`x'=std(`x')
}

foreach x of varlist gen rgen sgen  {
	la var `x' "Benefit generosity"
}

foreach x of varlist con rcon scon  {
	la var `x' "Qualifying period"
}

foreach x of varlist cov rcov scov  {
	la var `x' "Coverage"
}

foreach x of varlist rep rrep srep  {
	la var `x' "Replacement rate"
}

foreach x of varlist dur rdur sdur  {
	la var `x' "Duration"
}

foreach x of varlist wait rwait swait  {
	la var `x' "Waiting days"
}

keep country year gen cov con rep dur wait 
sort country year
order country 



*Save

save bengen.dta, replace

